<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi as UserApi;

/**
 * 后台首页控制器
 */
class IndexController extends AdminController {

    /**
     * 后台首页
     */
    public function index(){
    	
    	// 最近一次任务目标
    	$objId  = M('Objective')->max('id');
    	$objInfo = M('Objective')->find($objId);
    	
    	$yw = false;
    	if ( $this->_userInfo['group_id'] == '5') {
			
    		//获取完成进
    		$map['ordtime'][] = array('egt', $objInfo['time-start']);
    		$map['ordtime'][] = array('elt', $objInfo['time-end']);
    		$map['uid']	= UID;
    		$sum = M('Order')->where($map)->sum('ordfee');
    		
    		$yw = true;
    	} else {
    		//获取完成进
    		$map['ordtime'][] = array('egt', $objInfo['time-start']);
    		$map['ordtime'][] = array('elt', $objInfo['time-end']);
    		$sum = M('Order')->where($map)->sum('ordfee');

    	}
    	$this->assign('objInfo', $objInfo);
    	$this->assign('sum', $sum);
    	$this->assign('yw', $yw);

 		//最近的工作计划
 		$maps['uid'] = UID;
 		$mapss['uid'] = UID;
 		$mapss['is_view'] = 1;
 		$is_view = M('Task')->where($mapss)->count();
 		if ($is_view) {
 			$list = M('Task')->where($maps)->field(true)->order('is_view desc,reminder_time asc')->limit(6)->select();
 		} else {
 			$list = M('Task')->where($maps)->field(true)->order('id desc')->limit(6)->select();
 		}
 
 		
 		$this->assign('_list', $list);
 		
        $this->meta_title = '管理首页';
        $this->display();
    }

}
